#!/bin/bash
set -e
cd ${JM_SHARE_DIR}

sed -i "s/\[access_key_id\]/${JIANMU_ACCESS_KEY_ID}/" /root/.config/rclone/rclone.conf
sed -i "s/\[secret_access_key\]/${JIANMU_SECRET_ACCESS_KEY}/" /root/.config/rclone/rclone.conf
sed -i "s/\[end_point\]/${JIANMU_END_POINT}/" /root/.config/rclone/rclone.conf
rclone mkdir ${JIANMU_CONFIG_NAME}:${JIANMU_BUCKET}-${JIANMU_APPID}
rclone copy ${JIANMU_FILE_PATH} ${JIANMU_CONFIG_NAME}:${JIANMU_BUCKET}-${JIANMU_APPID}

echo "resultFile:"
echo -e "{\"cos_path\":\"${JIANMU_BUCKET}-${JIANMU_APPID}\"}" > resultFile
mv resultFile /usr

cat /usr/resultFile
